LicenseManager

@objc(LSLicenseManager)
final class LicenseManager : BaseManager
extension LicenseManager : CVarArg, CustomDebugStringConvertible, CustomStringConvertible, Equatable, Hashable, NSObjectProtocol

Entry point to the LicenseSpring SDK Use to obtain the license or common product information

  • Init LicenseManager with configuration

    Throws

    LSError if input configuration is wrong

    Declaration

    Swift

    override init(configuration: Configuration) throws

    Parameters

    configuration

    Configuration of LicenseManager

  • Activated License or nil if no license is active.

    Declaration

    Swift

    @objc
    var currentLicense: License? { get }
  • Activate the license using license key.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(licenseKey: String) throws -> License

    Parameters

    licenseKey

    License key for the product.

    Return Value

    Activated license.

  • Activate the license using a license key asynchronously.

    Declaration

    Swift

    @objc
    func activateLicense(licenseKey: String, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    licenseKey

    License key for the product.

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Activate the license using user and password.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(user: String, password: String) throws -> License

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    Return Value

    Activated license.

  • Activate the license using user and password asynchronously.

    Declaration

    Swift

    @objc
    func activateLicense(user: String, password: String, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Activate the license using serverId.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(user: String, password: String, serverId: Int64) throws -> License

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    Return Value

    Activated license.

  • Activate the license using user, password, and server ID asynchronously.

    Declaration

    Swift

    @objc
    func activateLicense(user: String, password: String, serverId: Int64, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    serverId

    License ID, typically a 64-bit ID.

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Activate the license using license activation response file.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicenseOffline(_ activationResponseFile: URL) throws -> License

    Parameters

    activationResponseFile

    Activation response file location.

    Return Value

    Activated license.

  • Activate the license using license activation response file asynchronously.

    Declaration

    Swift

    @objc
    func activateLicenseOffline(_ activationResponseFile: URL, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    activationResponseFile

    Activation response file location.

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Creates offline activation file request.

    Throws

    Error if create activation file fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func createOfflineActivationFile(licenseKey: String, preferredLocation: URL? = nil) throws -> URL

    Parameters

    licenseKey

    License key to be activated offline.

    preferredLocation

    Optional custom activation request file location. ‘~/Desktop/ls_activation.req’ by default.

    Return Value

    Location of offline activation file request.

  • Creates offline activation file request.

    Throws

    Error if create activation file fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func createOfflineActivationFile(user: String, password: String, preferredLocation: URL? = nil, serverID: Int64 = 0) throws -> URL

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    preferredLocation

    Optional custom activation request file location. ‘~/Desktop/ls_activation.req’ by default.

    serverID

    serverID, server-side license identifier, typically 64-bit id.

    Return Value

    Location of offline activation file request.

  • Get Activation code for air gap activation.

    Throws

    Error if generation fails. May be of LSError type.

    Declaration

    Swift

    @available(macOS, introduced: 10.15)
    @available(iOS, introduced: 13.0)
    @objc
    func generateAirGapActivationCode(initializationCode: String, licenseKey: String) throws -> String

    Parameters

    initializationCode

    Code received from the air gap activation portal.

    licenseKey

    License key of air gap license.

    Return Value

    Air gap Activation code. Empty string in case of error.

  • Verify Confirmation code for air gap activation.

    Throws

    Error if verification fails. May be of LSError type.

    Declaration

    Swift

    @available(macOS, introduced: 10.15)
    @available(iOS, introduced: 13.0)
    @objc
    func verifyAirGapConfirmationCode(confirmationCode: String, licenseKey: String, policyID: Int) throws

    Parameters

    confirmationCode

    Code received from the air gap activation portal.

    licenseKey

    License key of air gap license.

    policyID

    Policy id received from the air gap activation portal.

  • Activate air gap license using policy file.

    Throws

    Error if activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(airgapPolicyFile policyFile: URL, licenseKey: String, policyID: Int) throws -> License

    Parameters

    licenseKey

    License key.

    policyID

    Id of the license policy.

    Return Value

    License if activation succeeded.

  • Activate air gap license using policy file asynchronously.

    Declaration

    Swift

    @objc
    func activateLicense(airgapPolicyFile policyFile: URL, licenseKey: String, policyID: Int, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    licenseKey

    License key.

    policyID

    ID of the license policy.

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Retrieve URL for Single Sign-On license activation.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestSSOURL() throws -> URL

    Return Value

    URL for Single Sign-On.

  • Retrieve URL for Single Sign-On license activation.

    • completion: URL for Single Sign-On if request succeeds, Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestSSOURL(completion: @escaping (URL?, (any Error)?) -> Void)

    Parameters

    completion

    URL for Single Sign-On if request succeeds, Error if request fails. May be of LSError type.

  • Activate the license.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(ssoToken: String) throws -> License

    Parameters

    ssoToken

    id_token received from user authorization with SSO.

    Return Value

    Activated license.

  • Activate the license using SSO token asynchronously.

    Declaration

    Swift

    @objc
    func activateLicense(ssoToken: String, completion: @escaping (License?, (any Error)?) -> Void)

    Parameters

    ssoToken

    id_token received from user authorization with SSO.

    completion

    Completion handler called with the result of the activation. Returns License if activation succeeds, or Error if activation fails. The error may be of LSError type.

  • Request trial license from LicenseSpring platform.

    Throws

    Error if request fails. May be of LSError type.

    Note

    Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.

    Declaration

    Swift

    @objc
    func requestTrialKey(with email: String?) throws -> String

    Return Value

    Trial license key or user email in case of user-based product.

  • Request trial license from LicenseSpring platform.

    Throws

    Error if request fails. May be of LSError type.

    Note

    Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.

    Declaration

    Swift

    @objc
    func requestTrialKey(for customer: Customer?, licensePolicy: String? = nil) throws -> String

    Parameters

    licensePolicy

    License policy code. If nil, the default license policy for the product will be used.

    Return Value

    Trial license key or user email in case of user-based product.

  • Request trial license from LicenseSpring platform.

    Note

    Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.

    Declaration

    Swift

    @objc
    func requestTrialKey(with email: String?, completion: @escaping (String?, (any Error)?) -> Void)

    Parameters

    completion

    Trial license key or user email in case of user-based product if request succeeds, Error if request fails. May be of LSError type.

  • Request all available versions for the license user.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestAvailableVersions(licenseKey: String, env: String? = nil) throws -> [AvailableVersion]

    Parameters

    licenseKey

    License key.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    Return Value

    An array of versions available for the license.

  • Request all available versions for the license user.

    Declaration

    Swift

    @objc
    func requestAvailableVersions(licenseKey: String, env: String? = nil, completion: @escaping ([AvailableVersion]?, (any Error)?) -> Void)

    Parameters

    licenseKey

    License key.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    completion

    An array of versions available for the license if request succeeds, Error if request fails. May be of LSError type.

  • Request all available versions for the license user.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestAvailableVersions(user: String, env: String? = nil) throws -> [AvailableVersion]

    Parameters

    user

    License user name, usually email in lowercase.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    Return Value

    An array of versions available for the license.

  • Request all available versions for the license user.

    Declaration

    Swift

    @objc
    func requestAvailableVersions(user: String, env: String? = nil, completion: @escaping ([AvailableVersion]?, (any Error)?) -> Void)

    Parameters

    user

    License user name, usually email in lowercase.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    completion

    An array of versions available for the license if request succeeds, Error if request fails. May be of LSError type.

  • Request installation information for the license.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestInstallationFile(licenseKey: String, version: String? = nil, env: String? = nil) throws -> InstallationFile

    Parameters

    licenseKey

    License key.

    version

    Desired product (app) version, optional. If not provided, the last available version assumed.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    Return Value

    Installation information related to the license.

  • Request installation information for the license.

    Declaration

    Swift

    @objc
    func requestInstallationFile(licenseKey: String, version: String? = nil, env: String? = nil, completion: @escaping (InstallationFile?, (any Error)?) -> Void)

    Parameters

    licenseKey

    License key.

    version

    Desired product (app) version, optional. If not provided, the last available version assumed.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    completion

    Installation information related to the license if request succeeds, Error if request fails. May be of LSError type.

  • Request installation information for the license.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestInstallationFile(user: String, version: String? = nil, env: String? = nil) throws -> InstallationFile

    Parameters

    user

    License user name, usually email in lowercase.

    version

    Desired product (app) version, optional. If not provided, the last available version assumed.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    Return Value

    Installation information related to the license.

  • Request installation information for the license.

    Declaration

    Swift

    @objc
    func requestInstallationFile(user: String, version: String? = nil, env: String? = nil, completion: @escaping (InstallationFile?, (any Error)?) -> Void)

    Parameters

    user

    License user name, usually email in lowercase.

    version

    Desired product (app) version, optional. If not provided, the last available version assumed.

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    completion

    Installation information related to the license if request succeeds, Error if request fails. May be of LSError type.

  • Request information about the product from LicenseSpring platform.

    Throws

    Error if request fails. May be of LSError type.

    Note

    In offline mode data will be retrieved from license file if present.

    Declaration

    Swift

    @objc
    func requestProductDetails(env: String? = nil) throws -> ProductDetails

    Parameters

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    Return Value

    Product details.

  • Request information about the product from LicenseSpring platform.

    Note

    In offline mode data will be retrieved from license file if present.

    Declaration

    Swift

    @objc
    func requestProductDetails(env: String? = nil, completion: @escaping (ProductDetails?, (any Error)?) -> Void)

    Parameters

    env

    Environment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”

    completion

    Product details if request succeeds, Error if request fails. May be of LSError type.

  • Request all the license users on every order by some customer.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestLicenseUsers(for customerEmail: String) throws -> [User]

    Return Value

    Array of the users related to the customer.

  • Request all the license users on every order by some customer.

    Declaration

    Swift

    @objc
    func requestLicenseUsers(for customerEmail: String, completion: @escaping ([User]?, (any Error)?) -> Void)

    Parameters

    completion

    Array of the users related to the customer if request succeeds, Error if request fails. May be of LSError type.

  • Change password for user based license.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func changePassword(user: String, password: String, newPassword: String) throws

    Parameters

    user

    User email.

    password

    Current user password.

    newPassword

    New user password.

  • Change password for user based license.

    Declaration

    Swift

    @objc
    func changePassword(user: String, password: String, newPassword: String, completion: @escaping ((any Error)?) -> Void)

    Parameters

    user

    User email.

    password

    Current user password.

    newPassword

    New user password.

    completion

    Error if request fails. May be of LSError type.

  • Helper method to check connection to the LicenseSpring platform.

    Declaration

    Swift

    @objc
    func checkConnection() -> Bool

    Return Value

    true if SDK is able to connect to the LicenseSpring platform and false otherwise.

  • Helper method to check connection to the LicenseSpring platform.

    Declaration

    Swift

    @objc
    func checkConnection(completion: @escaping (Bool) -> Void)

    Parameters

    completion

    true if SDK is able to connect to the LicenseSpring platform and false otherwise

  • Remove license file and internal SDK files if any of them exist.

    Note

    Typically should be called after license deactivation in the app uninstaller.

    Throws

    Error if clearing fails.

    Declaration

    Swift

    @objc
    func clearLocalStorage() throws
  • Gets the users licences using user and password

    Declaration

    Swift

    @objc
    func getUserLicenses(user: String, password: String) throws -> [UserLicensesData]

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    Return Value

    Array of UserLicensesData

  • Gets the users licences using user and password

    Declaration

    Swift

    @objc
    func getUserLicenses(user: String, password: String, completion: @escaping ([UserLicensesData]?, (any Error)?) -> Void)

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    completion

    Array of UserLicensesData, Error if request fails. May be of LSError type.

  • Version of LicenseSpring SDK

    Declaration

    Swift

    @objc
    static let sdkVersion: String
  • Version of LicenseSpring API

    Declaration

    Swift

    @objc
    static let apiVersion: Int
  • Extract SSO license token from URL.

    Throws

    Error if urlString has invalid format or scheme mismatched.

    Declaration

    Swift

    @objc
    static func extractSSOToken(from urlString: String, scheme: String) throws -> String

    Parameters

    scheme

    Expected URL scheme to ensure URL is valid. If scheme mismatched, the error is thrown.

    Return Value

    SSO token to activate the license.